11. Lesson Review
In this lesson we learned…
What is the GPU?
The GPU is the graphical processing unit. It’s responsible for calculating all of the graphics operations the software is requesting. It is responsible for deciding how a scene will look from a given perspective. It takes into account shaders, object positions, etc. The GPU is responsible for the “eyes” of a VR scene. Remember that the GPU always has to do double the work each frame because of the two cameras or lenses.
What is the CPU?
The CPU is the central processing unit. It’s responsible for the “brains”, our script logic and physics calculations, of our VR application. Anything that we write in scripts or interactions we use physics for are handled by the CPU.
What is a draw call? How can we determine how many draw calls our model is using?
A draw call is an object being drawn on the screen. Each model, each material, and each light require draw calls.
Our draw calls are calculated by multiplying:
NumberOfObjects x NumberOfMaterials x NumberOfLights = NumberOfDrawCalls.
For example, if we have one model, with four materials, and two realtime lights, it becomes 8 draw calls. 1 model x 4 materials x 2 lights = 1 x 4 x 2 = 8 draw calls.
What is the purpose of the frame debugger? How do we use it?
Our frame debugger lets us examine each frame of our app and see how it’s rendered.
To get to the frame debugger, we go to Window > Frame Debugger (or Window > Analysis > Frame Debugger). Play the experience. With the experience playing, hit Enable in the Frame Debugger window. This will pause the scene so we can examine the frame in more detail.
How can we reduce the number of draw calls in our scene?
- Use baked lighting. This will reduce the number of draw calls significantly.
- Reduce the amount of lights.
- Reduce the amount of materials.
- Reduce the amount of objects.
- Using frustum culling - allowing the camera to only draw what it can see.
A common bottleneck for our GPU is the geometry in our VR scenes. How can we check our scene’s geometry?
Clicking on the Stats button in the Game window will allow us to inspect the geometry in our scene, by looking at the number of Tris and Verts. Tris are the amount of triangular primitives that the camera is currently rendering. Verts are the individual points that make up the endpoints or vertices of those triangular primitives.
** For mobile VR our goal is between 50 and 100,000 Tris or Verts. **
Ways to make geometry less expensive:
- Use simple models.
- Use fewer models in the scene overall.
What are SetPass calls and how do they differ from draw calls?
A pass is a single swipe through an object or scene to be rendered each frame. Reducing our SetPass calls will reduce the time needed to render each frame, which will increase our frame rate.
A SetPass call is a wipe through the whole scene. A draw call paints individual objects.
Ways to reduce SetPass calls:
- Reuse materials. (Texture atlasing can reduce this even further.)
- Avoid specialty shaders like transparency.
- Avoid real-time shadows.
Tip: Remember that the fewer materials in the scene the better. Simpler and fewer materials mean better performance.